<?php
/**
 * Description of
 *
 * @author Marco Mounzer
 * @email m.mounzer@gmail.com
 * @copyright 2013
 */
?>
<div style="border: 0px solid grey; width: 342px; padding: 0px">
    <?php
    $sql = 'SELECT * FROM photo WHERE car_id = ' . Database::GetIstance()->quote($obj->Id);
    $data = Database::GetIstance()->select($sql);
    if (count($data) > 0) {
        ?>
        <script type="text/javascript">
            $(document).ready(function () {
                $('.popup-gallery').magnificPopup({
                    delegate: 'a',
                    type: 'image',
                    tLoading: 'Loading image #%curr%...',
                    mainClass: 'mfp-img-mobile',
                    gallery: {
                        enabled: true,
                        navigateByImgClick: true,
                        preload: [0, 1] // Will preload 0 - before current, and 1 after the current image
                    },
                    image: {
                        tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
                        titleSrc: function (item) {
                            return '<small>by Automoda s.a.s.</small>';
                        }
                    }
                });
            });
        </script>
        <div class="popup-gallery">
            <?php
            $i = 0;
            foreach ($data as $v) {
                /* if ($i == 0) {
                  ?>
                  <a class="inner_main" id="a<?php echo $v->id; ?>" href="/images/cars/<?php echo $v->id . '.' . $v->extension; ?>" ord="<?php echo $i; ?>">
                  <img src="/images/cars/<?php echo $v->id . '.' . $v->extension; ?>" alt="" title="rrr" ord="<?php echo $i; ?>" style="max-height: 332px; max-width: 332px;"/>
                  </a>
                  <?php
                  } else { */
                ?>
                <a class="inner" id="a<?php echo $v->id; ?>" href="/images/cars/<?php echo $v->id . '.' . $v->extension; ?>" ord="<?php echo $i; ?>">
                    <img src="/images/cars/<?php echo $v->id . '.' . $v->extension; ?>" alt="" title="" ord="<?php echo $i; ?>" style="max-height: 100px; max-width: 100px;"/>
                </a>
                <?php
                //}
                $i++;
            }
            ?>
        </div>
        <?php
    }
    ?>
</div>